package com.kaijie.controller;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kaijie.entity.MoveCheckEntity;
import com.kaijie.entity.RoomInfnEntity;
import com.kaijie.entity.RoomSortInfnEntity;
import com.kaijie.service.MoveCheckService;
import com.kaijie.service.RoomInfnService;
import com.kaijie.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.kaijie.entity.RoomMoneyManageEntity;
import com.kaijie.service.RoomMoneyManageService;
import com.kaijie.utils.PageUtils;
import com.kaijie.utils.R;



/**
 * 
 *
 * @author Jy
 * @email 846021119@qq.com
 * @date 2022-02-28 12:02:21
 */
@RestController
@RequestMapping("kaijie/roommoneymanage")
public class RoomMoneyManageController {
    @Autowired
    private RoomMoneyManageService roomMoneyManageService;
    @Autowired
    RoomInfnService roomInfnService;
    @Autowired
    MoveCheckService moveCheckService;


    @RequestMapping("/selRmId/{rmid}")
    //@RequiresPermissions("kaijie:movecheck:info")
    public R selRmId(@PathVariable("rmid") Integer rmid){
        MoveCheckEntity moveCheck = moveCheckService.getOne(new QueryWrapper<MoveCheckEntity>().eq("rmid", rmid));
        //roomInfnEntity.setRemarks("");
        return R.ok().put("moveCheck", moveCheck);
    }


    @RequestMapping("/listID")
    //@RequiresPermissions("kaijie:roomsortinfn:list")
    public Map<String, Object> listID(@RequestParam Map<String, Object> params){
        List<RoomInfnEntity> roomInfnEntityList=roomInfnService.list();
        Map<String, Object> map = new HashMap<>();
        map.put("code",0);
        map.put("count",roomInfnEntityList.size());
        map.put("msg"," ");
        map.put("data",roomInfnEntityList);
        return map;
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("kaijie:roommoneymanage:list")
    public Map<String, Object> list(@RequestParam Map<String, Object> params){
        List<RoomMoneyManageEntity> r=roomMoneyManageService.list();
        Map<String, Object> map = new HashMap<>();
        map.put("code",0);
        map.put("count",r.size());
        map.put("msg"," ");
        map.put("data",r);
        return map;
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("kaijie:roommoneymanage:info")
    public R info(@PathVariable("id") Integer id){
        RoomMoneyManageEntity roomMoneyManage = roomMoneyManageService.getById(id);

        return R.ok().put("roomMoneyManage", roomMoneyManage);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("kaijie:roommoneymanage:save")
    public R save(@RequestBody RoomMoneyManageEntity roomMoneyManage){
        roomMoneyManageService.save(roomMoneyManage);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("kaijie:roommoneymanage:update")
    public R update(@RequestBody RoomMoneyManageEntity roomMoneyManage){
        ValidatorUtils.validateEntity(roomMoneyManage);
        roomMoneyManageService.updateById(roomMoneyManage);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("kaijie:roommoneymanage:delete")
    public R delete(@RequestBody Integer[] ids){
        roomMoneyManageService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
